package com.zt.controller;

import com.zt.common.Result;
import com.zt.pojo.UserRoles;
import com.zt.service.UserRolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sun.awt.image.IntegerComponentRaster;

@RestController
@RequestMapping("/api")
public class UserRolesController {
    @Autowired
    private UserRolesService userRolesService;

    /**
     * 为用户分配角色
     * @return
     */
    @PostMapping("/user_roles")
    public Result addUserroles(@RequestBody UserRoles userRoles){
        boolean save = userRolesService.save(userRoles);
        return save?Result.OK():Result.ERROR();
    }
    @DeleteMapping("/user_roles/{user_id}/{role_id}")
    public Result delete(@PathVariable Integer user_id, @PathVariable Integer role_id){
        return userRolesService.delete(user_id,role_id);
    }
}
